import { RouteRecordRaw } from 'vue-router'

const lazyLoadingComponents = () => {
    return {
        homeView: () => import('@/views/HomeView.vue'),
        fileCheckView: () => import('@/views/FileCheckView.vue'),
        adminView: () => import('@/views/AdminViews/AdminView.vue'),
        userManagementView: () => import('@/views/AdminViews/UserManagementView.vue'),
        fileManagementView: () => import('@/views/AdminViews/FileManagementView.vue'),
        deviceManagementView: () => import('@/views/AdminViews/DeviceManagementView.vue'),

        websiteManagementView: () => import('@/views/AdminViews/WebsiteManagementView/WebsiteManagementView.vue'),
        homeManagementView: () => import('@/views/AdminViews/WebsiteManagementView/HomeManagementView.vue'),
        fileCheckManagementView: () => import('@/views/AdminViews/WebsiteManagementView/FileCheckManagementView.vue')
    }
}
export const asyncRoutes: Array<RouteRecordRaw> = [
    // 异步路由
    {
        path: '/home',
        name: 'Home',
        component: lazyLoadingComponents().homeView,
        meta: { title: '首页', icon: 'home', iconColor: '#FFFFFF', roles: ['admin', 'user'] }
    },
    {
        path: '/playback',
        name: 'Playback',
        component: lazyLoadingComponents().fileCheckView,
        meta: { title: '文件查看', icon: 'fileCheck', iconColor: '#FFFFFF', roles: ['admin', 'user'] }
    },
    {
        path: '/admin',
        name: 'Admin',
        redirect: '/userManagement',
        component: lazyLoadingComponents().adminView,
        meta: { title: '平台管理', icon: 'system', iconColor: '#FFFFFF', roles: ['admin'] },
        children: [
            {
                path: '/userManagement',
                name: 'UserManagement',
                component: lazyLoadingComponents().userManagementView,
                meta: { title: '用户管理', icon: 'user_management', iconColor: '#FFFFFF', parentPath: '/admin' }
            },
            {
                path: '/fileManagement',
                name: 'FileManagement',
                component: lazyLoadingComponents().fileManagementView,
                meta: { title: '文件管理', icon: 'file_management', iconColor: '#FFFFFF', parentPath: '/admin' },
            },
            {
                path: '/deviceManagement',
                name: 'DeviceManagement',
                component: lazyLoadingComponents().deviceManagementView,
                meta: { title: '设备管理', icon: 'camera_management', iconColor: '#FFFFFF', parentPath: '/admin' }
            },
            {
                path: '/websiteManagement',
                name: 'WebsiteManagement',
                component: lazyLoadingComponents().websiteManagementView,
                meta: { title: '网站管理', icon: 'website_management', iconColor: '#FFFFFF', parentPath: '/admin' },
                children: [
                    {
                        path: '/homeManagement',
                        name: 'HomeManagement',
                        component: lazyLoadingComponents().homeManagementView,
                        meta: { title: '主页', icon: 'home', iconColor: '#FFFFFF', parentPath: '/websiteManagement' },
                    },
                    // {
                    //     path: '/fileCheckManagement',
                    //     name: 'FileCheckManagement',
                    //     component: lazyLoadingComponents().fileCheckManagementView,
                    //     meta: { title: '文件查看', icon: 'fileCheck', iconColor: '#FFFFFF', parentPath: '/websiteManagement' }
                    // },
                ]
            }
        ]
    }
]